package com.hnkywl.sts.action.tjbb;

import com.hnkywl.sts.service.tjbb.ZjzyService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Calendar;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: SDE09
 * Date: 13-9-28
 * Time: 下午5:06
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/tjbb/zjzy")
public class ZjzyAction extends SimpleActionSupport {
    private ZjzyService zjzyService;

    private Integer gsid;
    private Date enddt;
    private Integer type;
    private Integer tc_flag;
    private int page;
    private int rows;


    @Action("zjzy")
    public String zjzy() {

        /*     Calendar calendar = Calendar.getInstance();
        //得到月末
      calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
      enddt = calendar.getTime();*/
        enddt = new Date();
        return SUCCESS;
    }

    @Action("zjzyList")
    public void zjzyList() {
        Calendar calendar = Calendar.getInstance();
        if (enddt == null) {
            //得到月末
            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
            enddt = calendar.getTime();
            // enddt = new Date();
        }
        if (type == null) {
            type = 1;
        }
        if (tc_flag == null) {
            tc_flag = 1;
        }

        String json = zjzyService.zjzyList(gsid, enddt, type, tc_flag);
        renderJson(json);
    }

    //库存金额跳转页面
    @Action("bqkcje")
    public String bqkcje() {
        return SUCCESS;
    }

    //库存金额
    @Action("bgkcjelist")
    public void bgkcjelist() {
        renderText(zjzyService.bgkcje(gsid, type, enddt, tc_flag,page,rows));
    }

    //在途资金跳转页面
    @Action("bgztzj")
    public String bgztzj() {
        return SUCCESS;
    }

    //在途资金
    @Action("bqztzjlist")
    public void bqztzjlist() {
        renderText(zjzyService.bqztzj(gsid, type, enddt, tc_flag));
    }

    //预付款
    @Action("bgyufk")
    public String bgyufk() {
        return SUCCESS;
    }

    //预付款
    @Action("bgyufklist")
    public void bgyufklist() {
        renderText(zjzyService.bgyufk(gsid, enddt, type, tc_flag));
    }

    //应付款
    @Action("bgyingfk")
    public String bgyingfk() {
        return SUCCESS;
    }

    //应付款
    @Action("bgyingfklist")
    public void bgyingfklist() {
        renderText(zjzyService.bgyufk(gsid, enddt, type, tc_flag));
    }

    //应收款
    @Action("bgyingsk")
    public String bgyingsk() {
        return SUCCESS;
    }

    //应收款
    @Action("bgyingsklist")
    public void bgyingsklist() {
        renderText(zjzyService.bgyingsk(gsid, enddt, type, tc_flag));
    }

    //预收款
    @Action("bgyusk")
    public String bgyusk() {
        return SUCCESS;
    }

    //预收款
    @Action("bgyusklist")
    public void bgyusklist() {
        renderText(zjzyService.bgyingsk(gsid, enddt, type, tc_flag));
    }

    //==============getter====setter=================

    public Integer getGsid() {
        return gsid;
    }

    public void setGsid(Integer gsid) {
        this.gsid = gsid;
    }

    public Integer getTc_flag() {
        return tc_flag;
    }

    public void setTc_flag(Integer tc_flag) {
        this.tc_flag = tc_flag;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Date getEnddt() {
        return enddt;
    }

    public void setEnddt(Date enddt) {
        this.enddt = enddt;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    @Autowired
    public void setZjzyService(ZjzyService zjzyService) {
        this.zjzyService = zjzyService;
    }
}
